package com.wss.module.main.ui.page.selector;

import com.orhanobut.logger.Logger;
import com.wss.common.base.BaseActionBarAbility;
import com.wss.module.main.ResourceTable;
import com.wss.module.main.bean.Province;
import com.wss.module.main.ui.page.selector.mvp.SelectorPresenter;
import com.wss.module.main.ui.page.selector.mvp.contract.SelectContract;
import com.wss.module.main.ui.page.selector.slice.SelectorAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.IntentAbility;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.IntentParams;
import ohos.agp.components.Component;
import ohos.agp.components.TimePicker;
import ohos.bundle.BundleInfo;
import ohos.event.intentagent.IntentAgent;
import ohos.utils.IntentConstants;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * Describe：多种选择器
 * Created by 吴天强 on 2018/10/24.
 */
public class SelectorAbility extends BaseActionBarAbility<SelectorPresenter>
        implements SelectContract.View,
        Component.ClickedListener {

    private Calendar selectDate;
    private List<Province> options1Items = new ArrayList<>();
    private List<List<String>> options2Items = new ArrayList<>();
    private List<List<List<String>>> options3Items = new ArrayList<>();
    /**
     * 农历日历
     */
    private TimePicker lunarPicker;

    /**
     * 自定义
     */
    private List<String> user = new ArrayList<>();
    private List<String> userFrom = new ArrayList<>();
    private List<String> userDes = new ArrayList<>();

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        initView();
        initListener();
    }

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_selector;
    }

    private void initView() {
        setCenterText("多功能选择器");
        selectDate = Calendar.getInstance();
        getPresenter().start();
    }

    private void initListener() {
        findComponentById(ResourceTable.Id_btn_01).setClickedListener(this::onClick);
        findComponentById(ResourceTable.Id_btn_02).setClickedListener(this::onClick);
        findComponentById(ResourceTable.Id_btn_03).setClickedListener(this::onClick);
        findComponentById(ResourceTable.Id_btn_04).setClickedListener(this::onClick);
        findComponentById(ResourceTable.Id_btn_05).setClickedListener(this::onClick);
        findComponentById(ResourceTable.Id_btn_06).setClickedListener(this::onClick);
    }

    @Override
    public void onClick(Component component) {
        if (component.getId() == ResourceTable.Id_btn_01) {
            //日期选择器
//            showDateTime();
        } else if (component.getId() == ResourceTable.Id_btn_02) {
            //地址三级联动
//            showAddress();
        } else if (component.getId() == ResourceTable.Id_btn_03) {
            //带农历日期选择器
//            showLunarPicker();
        } else if (component.getId() == ResourceTable.Id_btn_04) {
            //单行选择器
//            showUserList();
        } else if (component.getId() == ResourceTable.Id_btn_05) {
            //多级不联动选择器
//            showUserInfoList();
        } else if (component.getId() == ResourceTable.Id_btn_06) {
            //自定义日期选择器
            new SelectorDatePopupWindow(context, component).show();
        }
    }

    /**
     * 农历时间已扩展至 ： 1900 - 2100年
     */
    private void showLunarPicker() {
        //系统当前时间
        Calendar selectedDate = Calendar.getInstance();
        Calendar startDate = Calendar.getInstance();
        startDate.set(2014, 1, 23);
        Calendar endDate = Calendar.getInstance();
        endDate.set(2069, 2, 28);
    }

    @Override
    protected SelectorPresenter createPresenter() {
        return new SelectorPresenter();
    }

    @Override
    public void refreshAddressList(List<Province> options1Items, List<List<String>> options2Items, List<List<List<String>>> options3Items) {

    }

    @Override
    public void refreshNonLinkageList(List<String> userList, List<String> userFrom, List<String> userDes) {

    }
}
